/*错误提示弹框*/
function errorMsg(msg) {
	layer.msg(msg, {
		anim: 6,
		time: 1500
	});
}
/*普通提示弹框*/
function Msg(msg) {
	layer.msg(msg, {
		time: 1000
	});
}
/*关闭所有弹框*/
function layer_close() {
	layer.closeAll()
}
/*loading*/
function loading() {
	var html = '<div class="Loading_layer">' +
		'<div  class="Loading_layer_in">' +
		'<img class="xuanzhuan_animation" src="static/images/logo.png" />' +
		'</div>' +
		'</div>'
	$(html).prependTo('body');
}
/*处理输入法顶起底部bar的问题*/
var windheight = $(window).height(); /*未唤起键盘时当前窗口高度*/
$(window).resize(function() {
	var docheight = $(window).height(); /*唤起键盘时当前窗口高度*/
	if(docheight < windheight) { /*当唤起键盘高度小于未唤起键盘高度时执行*/
		$(".footer_bar,.back_top,.contact_bottom,.next_fill").css("position", "static");
	} else {
		$(".footer_bar,.back_top,.contact_bottom,.next_fill").css("position", "fixed");
	}
});
/*点击底部bar切换样式*/
$(document).on("click", (".footer_bar a"), function() {
	$(this).siblings("a").removeClass("footer_bar_action");
	$(this).addClass("footer_bar_action");
})
/*返回顶部*/
$(function() {
	$(document).scroll(function() {
		if($(window).scrollTop() > 200) {
			$(".back_top").fadeIn();
		} else {
			$(".back_top").hide();
		}
	})
	$(".back_top").click(function() {
		$("html,body").animate({
			scrollTop: 0
		}, 500);
	})
})
$(function() {
	/*点击图片全屏滑动预览*/
	var swiperStatus;
	imgsdata = {
		"list1": ["changkuan11.png", "changkuan12.png", "index_banner.jpg", "changkuan11.png", "changkuan12.png", "index_banner.jpg", "changkuan11.png"],
		"list2": [ "changkuan12.png","changkuan11.png", "changkuan12.png", "index_banner.jpg"]
	}
	var swiper_full = new Swiper('.swiper_full', {
		zoom: true,
		width: window.innerWidth,
		virtual: true,
		spaceBetween: 20,
		pagination: {
			el: '.swiper-pagination',
			type: 'fraction',
		},
		on: {
			click: function() {
				$('#origin-img').fadeOut('fast');
				this.virtual.slides.length = 0;
				this.virtual.cache = [];
				swiperStatus = false;

			},
		},

	});
	$(document).on("click", (".swiper-wrapper a"), function() {
		console.log("ss")
		clickIndex = $(this).index();
		imglist = $(this).parent().attr('thumblist');
		imgs = imgsdata[imglist];
		for(i = 0; i < imgs.length; i++) {
			swiper_full.virtual.appendSlide('<div class="swiper-zoom-container"><img src="static/images/' + imgs[i] + '" /></div>');
		}
		swiper_full.slideTo(clickIndex);
		$('#origin-img').fadeIn('fast');
		swiperStatus = true;
	})

	//切换图状态禁止页面缩放	
	document.addEventListener('touchstart', function(event) {
		if(event.touches.length > 1 && swiperStatus) {
			event.preventDefault();
		}
	})
	var lastTouchEnd = 0;
	document.addEventListener('touchend', function(event) {
		var now = (new Date()).getTime();
		if(now - lastTouchEnd <= 300) {
			event.preventDefault();
		}
		lastTouchEnd = now;
	}, false)

	document.addEventListener('touchmove', function(e) {
		if(swiperStatus) {
			e.preventDefault();
		}
	})
})